import random

# def myfun(f):
#     def fun():
#         print(f"开始执行目标函数{f.__name__}")
#         f()
#         print(f"执行目标函数结束{f.__name__}")
#     return fun
#
# @myfun
# def f2():
#     print(f"醒醒啦")
#
# # f2 = myfun(f2)
# # print(f2.__name__)
# f2()
#
#
# @myfun
# def f3():
#     print(f"饿了么")
#
# f3()


# import copy
# import time


# def cost_time(f):
#     def calc():
#         start = time.time()
#         f()
#         print(f"{f.__name__} 花费{time.time()-start}")
#     return calc
#
#
# l = [random.randint(0, 100000) for i in range(10000)]
# l2 = copy.deepcopy(l)
#
#
# @cost_time
# def sort1():
#     l.sort(reverse=False)
#
# # sort1 = cost_time(sort1)
#
# sort1()
#
#
# @cost_time
# def sort2():
#     for i in range(len(l2)-1):
#         max_index = i
#         for j in range(i+1, len(l2)):
#             if l2[j] > l2[max_index]:
#                 max_index = j
#
#         if max_index != i:
#             temp = l2[i]
#             l2[i] = l2[max_index]
#             l2[max_index] = temp
#
# # sort2 = cost_time(sort2)
# sort2()



def login_required(f):
    def check():
        if not current_user:
            login()
        f()

    return check




current_user = None


def index():
    print(f"首页")


index()

def login():
    global current_user
    while True:
        username = input("输入用户名")
        password = input("输入密码")
        if username == "admin" and password == "123":
            current_user = "admin"
            print(f"登录成功")
            break
        else:
            print(f"登录失败")


@login_required
def center():
    print(f"个人中心  当前用户{current_user}")




# center = login_required(center)

center()



@login_required
def order():
    print(f"订单列表 当前用户{current_user}")


order()